<?php

class Url {

    public static function base($protocol = 'http', $port = null) {
        if ($port == null)
            $port = DSF_URLAPPPORT;
        if ($port == '80')
            $port = '';
        else
            $port = ':' . $port;

        $appPath = DSF_URLAPPPATH;
        $appHost = DSF_URLAPPHOST;
        return "{$protocol}://{$appHost}{$port}{$appPath}";
    }

    public static function site($site = '') {
        if ($site == '')
            $site = DSF_URLDEFCONT . '/' . DSF_URLDEFACT;
        return self::base() . "index.php/{$site}";
    }

    public static function redirect($site = '', $framework = true) {
        if ($framework)
            $url = self::site($site);
        else
            $url = self::base() . "{$site}";
        header("Location: {$url}");
        exit;
    }

}

?>
